//
// Created by none98 on 2021/9/14.
//

#ifndef LOGINSERVER_TIMEREVENTQUEUE_H
#define LOGINSERVER_TIMEREVENTQUEUE_H

#include <queue>
#include <map>
#include "CallBacks.h"
#include "TimeStamp.h"

class Timer;
class TimerEventQueue {
public:
    TimerEventQueue() = default;
    ~TimerEventQueue() = default;

    std::vector<TimerCallBack> GetExpiredEvents(const TimeStamp &expire);
    long AddTimer(const Timer& timer);
    void CancelTimerByFd(int fd);
    void CancelTimerBySequence(long seq);
private:
    std::mutex objectMutex;
    long sequence;
    std::multimap<Timer,long> timerMap;
};

#endif //LOGINSERVER_TIMEREVENTQUEUE_H
